\(\int (a+b \cos (c+d x)) (A+B \cos (c+d x)+C \cos ^2(c+d x)) \sec (c+d x) \, dx\) [941]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 37, antiderivative size = 69 \[ \int (a+b \cos (c+d x)) \left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x) \, dx=\frac {1}{2} (2 A b+2 a B+b C) x+\frac {a A \text {arctanh}(\sin (c+d x))}{d}+\frac {(b B+a C) \sin (c+d x)}{d}+\frac {b C \cos (c+d x) \sin (c+d x)}{2 d} \]

[Out]

1/2*(2*A*b+2*B*a+C*b)*x+a*A*arctanh(sin(d*x+c))/d+(B*b+C*a)*sin(d*x+c)/d+1/2*b*C*cos(d*x+c)*sin(d*x+c)/d

Rubi [A] (verified)

Time = 0.15 (sec) , antiderivative size = 69, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.108, Rules used = {3112, 3102, 2814, 3855} \[ \int (a+b \cos (c+d x)) \left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x) \, dx=\frac {a A \text {arctanh}(\sin (c+d x))}{d}+\frac {1}{2} x (2 a B+2 A b+b C)+\frac {(a C+b B) \sin (c+d x)}{d}+\frac {b C \sin (c+d x) \cos (c+d x)}{2 d} \]

[In]

Int[(a + b*Cos[c + d*x])*(A + B*Cos[c + d*x] + C*Cos[c + d*x]^2)*Sec[c + d*x],x]

[Out]

((2*A*b + 2*a*B + b*C)*x)/2 + (a*A*ArcTanh[Sin[c + d*x]])/d + ((b*B + a*C)*Sin[c + d*x])/d + (b*C*Cos[c + d*x]
*Sin[c + d*x])/(2*d)

Rule 2814

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[b*(x/d)
, x] - Dist[(b*c - a*d)/d, Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d
, 0]

Rule 3102

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*sin[(e_.) + (f_.)*(x_)] + (C_.)*sin[(e_.) + (
f_.)*(x_)]^2), x_Symbol] :> Simp[(-C)*Cos[e + f*x]*((a + b*Sin[e + f*x])^(m + 1)/(b*f*(m + 2))), x] + Dist[1/(
b*(m + 2)), Int[(a + b*Sin[e + f*x])^m*Simp[A*b*(m + 2) + b*C*(m + 1) + (b*B*(m + 2) - a*C)*Sin[e + f*x], x],
x], x] /; FreeQ[{a, b, e, f, A, B, C, m}, x] &&  !LtQ[m, -1]

Rule 3112

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.)*((c_) + (d_.)*sin[(e_.) + (f_.)*(x_)])*((A_.) + (B_.)*sin[(e
_.) + (f_.)*(x_)] + (C_.)*sin[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[(-C)*d*Cos[e + f*x]*Sin[e + f*x]*((a +
 b*Sin[e + f*x])^(m + 1)/(b*f*(m + 3))), x] + Dist[1/(b*(m + 3)), Int[(a + b*Sin[e + f*x])^m*Simp[a*C*d + A*b*
c*(m + 3) + b*(B*c*(m + 3) + d*(C*(m + 2) + A*(m + 3)))*Sin[e + f*x] - (2*a*C*d - b*(c*C + B*d)*(m + 3))*Sin[e
 + f*x]^2, x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B, C, m}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 0] &&
  !LtQ[m, -1]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps \begin{align*} \text {integral}& = \frac {b C \cos (c+d x) \sin (c+d x)}{2 d}+\frac {1}{2} \int \left (2 a A+(2 A b+2 a B+b C) \cos (c+d x)+2 (b B+a C) \cos ^2(c+d x)\right ) \sec (c+d x) \, dx \\ & = \frac {(b B+a C) \sin (c+d x)}{d}+\frac {b C \cos (c+d x) \sin (c+d x)}{2 d}+\frac {1}{2} \int (2 a A+(2 A b+2 a B+b C) \cos (c+d x)) \sec (c+d x) \, dx \\ & = \frac {1}{2} (2 A b+2 a B+b C) x+\frac {(b B+a C) \sin (c+d x)}{d}+\frac {b C \cos (c+d x) \sin (c+d x)}{2 d}+(a A) \int \sec (c+d x) \, dx \\ & = \frac {1}{2} (2 A b+2 a B+b C) x+\frac {a A \text {arctanh}(\sin (c+d x))}{d}+\frac {(b B+a C) \sin (c+d x)}{d}+\frac {b C \cos (c+d x) \sin (c+d x)}{2 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.12 (sec) , antiderivative size = 68, normalized size of antiderivative = 0.99 \[ \int (a+b \cos (c+d x)) \left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x) \, dx=\frac {2 b c C+4 A b d x+4 a B d x+2 b C d x+4 a A \text {arctanh}(\sin (c+d x))+4 (b B+a C) \sin (c+d x)+b C \sin (2 (c+d x))}{4 d} \]

[In]

Integrate[(a + b*Cos[c + d*x])*(A + B*Cos[c + d*x] + C*Cos[c + d*x]^2)*Sec[c + d*x],x]

[Out]

(2*b*c*C + 4*A*b*d*x + 4*a*B*d*x + 2*b*C*d*x + 4*a*A*ArcTanh[Sin[c + d*x]] + 4*(b*B + a*C)*Sin[c + d*x] + b*C*
Sin[2*(c + d*x)])/(4*d)

Maple [A] (verified)

Time = 0.27 (sec) , antiderivative size = 82, normalized size of antiderivative = 1.19

method result size
derivativedivides \(\frac {a A \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+B a \left (d x +c \right )+C \sin \left (d x +c \right ) a +A b \left (d x +c \right )+B \sin \left (d x +c \right ) b +C b \left (\frac {\cos \left (d x +c \right ) \sin \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )}{d}\) \(82\)
default \(\frac {a A \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+B a \left (d x +c \right )+C \sin \left (d x +c \right ) a +A b \left (d x +c \right )+B \sin \left (d x +c \right ) b +C b \left (\frac {\cos \left (d x +c \right ) \sin \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )}{d}\) \(82\)
parallelrisch \(\frac {-4 a A \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )+4 a A \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )+C \sin \left (2 d x +2 c \right ) b +\left (4 B b +4 C a \right ) \sin \left (d x +c \right )+4 x d \left (B a +b \left (A +\frac {C}{2}\right )\right )}{4 d}\) \(82\)
parts \(\frac {a A \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{d}+\frac {\left (A b +B a \right ) \left (d x +c \right )}{d}+\frac {\left (B b +C a \right ) \sin \left (d x +c \right )}{d}+\frac {C b \left (\frac {\cos \left (d x +c \right ) \sin \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )}{d}\) \(83\)
risch \(x A b +x B a +\frac {b C x}{2}-\frac {i {\mathrm e}^{i \left (d x +c \right )} B b}{2 d}-\frac {i {\mathrm e}^{i \left (d x +c \right )} C a}{2 d}+\frac {i {\mathrm e}^{-i \left (d x +c \right )} B b}{2 d}+\frac {i {\mathrm e}^{-i \left (d x +c \right )} C a}{2 d}+\frac {a A \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{d}-\frac {a A \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{d}+\frac {\sin \left (2 d x +2 c \right ) C b}{4 d}\) \(138\)
norman \(\frac {\left (A b +B a +\frac {1}{2} C b \right ) x +\left (A b +B a +\frac {1}{2} C b \right ) x \left (\tan ^{6}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (3 A b +3 B a +\frac {3}{2} C b \right ) x \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (3 A b +3 B a +\frac {3}{2} C b \right ) x \left (\tan ^{4}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\frac {\left (2 B b +2 C a -C b \right ) \left (\tan ^{5}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}+\frac {\left (2 B b +2 C a +C b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d}+\frac {4 \left (B b +C a \right ) \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}}{\left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )^{3}}+\frac {a A \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{d}-\frac {a A \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{d}\) \(221\)

[In]

int((a+b*cos(d*x+c))*(A+B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c),x,method=_RETURNVERBOSE)

[Out]

1/d*(a*A*ln(sec(d*x+c)+tan(d*x+c))+B*a*(d*x+c)+C*sin(d*x+c)*a+A*b*(d*x+c)+B*sin(d*x+c)*b+C*b*(1/2*cos(d*x+c)*s
in(d*x+c)+1/2*d*x+1/2*c))

Fricas [A] (verification not implemented)

none

Time = 0.31 (sec) , antiderivative size = 73, normalized size of antiderivative = 1.06 \[ \int (a+b \cos (c+d x)) \left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x) \, dx=\frac {{\left (2 \, B a + {\left (2 \, A + C\right )} b\right )} d x + A a \log \left (\sin \left (d x + c\right ) + 1\right ) - A a \log \left (-\sin \left (d x + c\right ) + 1\right ) + {\left (C b \cos \left (d x + c\right ) + 2 \, C a + 2 \, B b\right )} \sin \left (d x + c\right )}{2 \, d} \]

[In]

integrate((a+b*cos(d*x+c))*(A+B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c),x, algorithm="fricas")

[Out]

1/2*((2*B*a + (2*A + C)*b)*d*x + A*a*log(sin(d*x + c) + 1) - A*a*log(-sin(d*x + c) + 1) + (C*b*cos(d*x + c) +
2*C*a + 2*B*b)*sin(d*x + c))/d

Sympy [F]

\[ \int (a+b \cos (c+d x)) \left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x) \, dx=\int \left (a + b \cos {\left (c + d x \right )}\right ) \left (A + B \cos {\left (c + d x \right )} + C \cos ^{2}{\left (c + d x \right )}\right ) \sec {\left (c + d x \right )}\, dx \]

[In]

integrate((a+b*cos(d*x+c))*(A+B*cos(d*x+c)+C*cos(d*x+c)**2)*sec(d*x+c),x)

[Out]

Integral((a + b*cos(c + d*x))*(A + B*cos(c + d*x) + C*cos(c + d*x)**2)*sec(c + d*x), x)

Maxima [A] (verification not implemented)

none

Time = 0.23 (sec) , antiderivative size = 82, normalized size of antiderivative = 1.19 \[ \int (a+b \cos (c+d x)) \left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x) \, dx=\frac {4 \, {\left (d x + c\right )} B a + 4 \, {\left (d x + c\right )} A b + {\left (2 \, d x + 2 \, c + \sin \left (2 \, d x + 2 \, c\right )\right )} C b + 4 \, A a \log \left (\sec \left (d x + c\right ) + \tan \left (d x + c\right )\right ) + 4 \, C a \sin \left (d x + c\right ) + 4 \, B b \sin \left (d x + c\right )}{4 \, d} \]

[In]

integrate((a+b*cos(d*x+c))*(A+B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c),x, algorithm="maxima")

[Out]

1/4*(4*(d*x + c)*B*a + 4*(d*x + c)*A*b + (2*d*x + 2*c + sin(2*d*x + 2*c))*C*b + 4*A*a*log(sec(d*x + c) + tan(d
*x + c)) + 4*C*a*sin(d*x + c) + 4*B*b*sin(d*x + c))/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 159 vs. \(2 (65) = 130\).

Time = 0.32 (sec) , antiderivative size = 159, normalized size of antiderivative = 2.30 \[ \int (a+b \cos (c+d x)) \left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x) \, dx=\frac {2 \, A a \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - 2 \, A a \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) + {\left (2 \, B a + 2 \, A b + C b\right )} {\left (d x + c\right )} + \frac {2 \, {\left (2 \, C a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 2 \, B b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - C b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 2 \, C a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 2 \, B b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + C b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 1\right )}^{2}}}{2 \, d} \]

[In]

integrate((a+b*cos(d*x+c))*(A+B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c),x, algorithm="giac")

[Out]

1/2*(2*A*a*log(abs(tan(1/2*d*x + 1/2*c) + 1)) - 2*A*a*log(abs(tan(1/2*d*x + 1/2*c) - 1)) + (2*B*a + 2*A*b + C*
b)*(d*x + c) + 2*(2*C*a*tan(1/2*d*x + 1/2*c)^3 + 2*B*b*tan(1/2*d*x + 1/2*c)^3 - C*b*tan(1/2*d*x + 1/2*c)^3 + 2
*C*a*tan(1/2*d*x + 1/2*c) + 2*B*b*tan(1/2*d*x + 1/2*c) + C*b*tan(1/2*d*x + 1/2*c))/(tan(1/2*d*x + 1/2*c)^2 + 1
)^2)/d

Mupad [B] (verification not implemented)

Time = 2.44 (sec) , antiderivative size = 156, normalized size of antiderivative = 2.26 \[ \int (a+b \cos (c+d x)) \left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x) \, dx=\frac {B\,b\,\sin \left (c+d\,x\right )}{d}+\frac {C\,a\,\sin \left (c+d\,x\right )}{d}+\frac {2\,A\,a\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}+\frac {2\,A\,b\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}+\frac {2\,B\,a\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}+\frac {C\,b\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}+\frac {C\,b\,\sin \left (2\,c+2\,d\,x\right )}{4\,d} \]

[In]

int(((a + b*cos(c + d*x))*(A + B*cos(c + d*x) + C*cos(c + d*x)^2))/cos(c + d*x),x)

[Out]

(B*b*sin(c + d*x))/d + (C*a*sin(c + d*x))/d + (2*A*a*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/d + (2*A*b*
atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/d + (2*B*a*atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/d + (C*b*
atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/d + (C*b*sin(2*c + 2*d*x))/(4*d)